/*
 * Logging.h
 *
 *  Created on: 2021年4月5日
 *      Author: san
 */

#ifndef BASE_LOGGING_H_
#define BASE_LOGGING_H_

#include "LogStream.h"

namespace san {

class Logger {
public:
	Logger(const char *fileName, int line);
	~Logger();
	LogStream &stream() { return impl_.stream_; }

	static void setLogFileName(const std::string &filename) { logFileName_ = filename; }
	static std::string getLogFileName() { return logFileName_; }

private:
	class Impl
	{
	public:
		Impl(const char *fileName, int line);
		void formatTime();

		LogStream stream_;
		int line_;
		std::string basename_;
	};

	Impl impl_;
	static std::string logFileName_;
};

} /* namespace san */

#define LOG Logger(__FILE__, __LINE__).stream()

#endif /* BASE_LOGGING_H_ */
